package com.bawei.goods.hospital_goods.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.bawei.goods.hospital_goods.entity.GoodTableEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bawei.goods.hospital_goods.entity.GoodTypeEntity;
import com.bawei.goods.hospital_goods.service.GoodTypeService;
import com.bawei.common.utils.PageUtils;
import com.bawei.common.utils.R;



/**
 * 
 *
 * @author doujunxian
 * @email 602137101@gmail.com
 * @date 2021-12-09 18:45:27
 */
@RestController
@RequestMapping("hospital_goods/goodtype")
public class GoodTypeController {
    @Autowired
    private GoodTypeService goodTypeService;

    /**
     * 查询所有数据
     */
    @GetMapping("/listAll")
    public R listAll(){
        List<GoodTypeEntity> list = goodTypeService.list();

        return R.ok().put("goods", list);
    }

    /**
     * 列表
     */
    @PostMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = goodTypeService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 修改
     */
    @PutMapping("/update/{id}")
    public R update(String row,@PathVariable("id") String id){
        goodTypeService.updateRow(id,row);

        return R.ok();
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
        public R info(@PathVariable("id") Long id){
		GoodTypeEntity goodType = goodTypeService.getById(id);

        return R.ok().put("goodType", goodType);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
        public R save(@RequestBody GoodTypeEntity goodType){


        goodTypeService.save(goodType);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
        public R update(@RequestBody GoodTypeEntity goodType){
		goodTypeService.updateById(goodType);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
        public R delete(@RequestBody Long[] ids){
		goodTypeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
